//
//  WBBaseTableViewController.swift
//  Weibo
//
//  Created by xu on 2017/3/19.
//  Copyright © 2017年 xuantong. All rights reserved.
//

import UIKit

class WBBaseTableViewController: UITableViewController,WBVisitorLoginViewDelegate {

    ///定义用户是否登录的标记
    var userLogin = WBUserAccountViewModel.shared.userLogin
    
    lazy var visitorView: WBVisitorLoginView = WBVisitorLoginView(frame: UIScreen.main.bounds)

    
    override func loadView() {
        
        if userLogin == true {
            
            super.loadView()
            
        }else{
            
            //用户没有登录时候进行设置
            self.view = visitorView
            
            visitorView.delegate = self
            
            visitorView.loginButton.addTarget(self, action: #selector(userWillLogin), for: .touchUpInside)
            
            visitorView.registerBtn.addTarget(self, action: #selector(userWillRegister), for: .touchUpInside)
            
        }
    }
    
    
    
    //登录
    func userWillLogin() {
        print(#function)
        
        //跳转
        let oauth = WBOAuthTableViewController()
        let nav = UINavigationController(rootViewController: oauth)
        self.present(nav, animated: true, completion: nil)
    }
    
    
    //注销
    func userWillRegister() {
        
        print(#function)

    }
    
    
    
    
    override func viewDidLoad() {
       
        super.viewDidLoad()
  }
    

}
